#pragma once

namespace struggle
{
	template<class T>
	struct list_node
	{
		list_node<T>* _next;
		list_node<T>* _prev;
		T _val;

		list_node(const T& val = T())
			:_next(nullptr)
			, _prev(nullptr)
			,_val(val)
	};
	template<class T>
	struct _list_iterator
	{
		typedef list_node<T> Node;
		Node* _node;

		_list_iterator(Node* node)
			:_node(node)
		{}

		T& operator*()
		{
			return _node->_val;
		}

		_list_iterator<T>& operator++(int)
		{
			_list_iterator<T> tmp(*this);
			_node = _node->_next;
			return tmp;
		}

		_list_iterator<T>& operator++()
		{
			
			_node = _node->_next;
			return _node;
		}

		bool operator!=(const _list_const_iterator<T>& it)
		{
			return _node != it._node;
		}

		bool operator==(const _list_iterator<T>& it)
		{
			return _node == it._node;
		}
	};
	template<class T>
	class list
	{
		typedef list_node<T> Node;
	public:
		typedef _list_iterator<T> iterator;
		iterator begin()
		{
			return _head->next
		}

		iterator end()
		{
			return _head;
		}

		list()
		{
			_head = new Node;
			_head-> prev = _head;
			_head->next = _head;
		}

		~list()
		{
			_head = delete Node;
			_head->prev = _head;
			_head->next = _head;
		}

		void push_back(const T& x)
		{
			Node* tail = _head->_prev;
			Node* newnode = new Node(x);
			tail->_next = newnode;
			newnode->_prev = tail;
			newnode->_next = _head;
			_head->_prev = newnode;
		}

	private:
		Node* _head;
	};
}

typedef list_iterator<T, Ref> self;

typedef list_iterator<Ref> self;

template<class T,class Ref>
T fac(T a, T b)
{

}

Ref fac(Ref a, Ref b)
{

}

template<class T, class Ref, class Ptr>
typedef struct __list_iterator<T, Ref, Ptr>
{
	typedef list_node<T> Node;
	//typedef __list_iterator<T, Ref, Ptr> self;
	Node* _node;
}self;
